package learn.advance.tcp;


import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

class DemoTCPClient{
    public static void Test() throws IOException {
        Socket socket=new Socket("127.0.0.1",20000);
        OutputStream os=socket.getOutputStream();
        os.write("你好服务器".getBytes());

        InputStream is=socket.getInputStream();
        byte[] bytes=new byte[1024];
        int len=is.read(bytes);

        System.out.println(new String(bytes,0,len));
        socket.close();
    }
}


public class TestTCPClient {
    public static void main(String[] args) throws IOException {
        Demo1TCPClient.Test();
    }
}
